<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>五维矩阵后台管理系统-主界面-自主式后台管理，简单直观，上手快</title>
    <link rel="stylesheet" href="./css/bootstrap.min.css" />
    <!--<link rel="stylesheet" href="./css/wangEditor.min.css" />-->
    <link rel="stylesheet" href="./css/reset.css" />
    <link rel="stylesheet" href="./css/panel.css" />
</head>
<body>
    <div class="leftSide">
        <div class="logoContent">
            <img src="./img/logo.svg" alt="五维矩阵" />
        </div>
        <div class="navContent">
            <ul>
                <!--<li class="current">-->
                    <!--<div class="iconContent"></div>-->
                    <!--<span>基本信息</span>-->
                <!--</li>-->
                <!--<li>-->
                    <!--<div class="iconContent"></div>-->
                    <!--<span>文章管理</span>-->
                <!--</li>-->
            </ul>
        </div>
    </div>
    <div class="rightSide">
        <div class="headerContent">
            <div class="searchContent">
                <div class="searchBtn"></div>
                <input type="text" placeholder="请输入要查找的文章标题" />
            </div>
            <div class="userPanel" style="visibility: hidden;">
                <div class="userHead"></div>
                <div class="setting"></div>
                <div class="logout"></div>
            </div>
        </div>
        <div class="bodyContent">
            <div class="bodyTitle">
                <p>文章管理</p>
            </div>
            <div class="actionContent">
                <div class="actionDeleteBtn" style="visibility: hidden !important;">
                    <img src="./img/delete_icon.png" alt="删除">
                    <span>删除</span>
                </div>
                <div class="actionAddBtn">
                    <img src="./img/add_icon.png" alt="增加">
                    <span>增加</span>
                </div>
            </div>
            <table class="table table-bordered">
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
    <!--删除模态框-->
    <div class="modal fade bs-example-modal-sm" id="deleteModal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header" style="border: none;">
                    <button type="button" class="close deleteCancelBtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body" style="text-align: center;">
                    <h4>确认删除？<font style="color:red;">(一经删除无法更改)</font></h4>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default deleteCancelBtn" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary deleteSubmitBtn">确定</button>
                </div>
            </div>
        </div>
    </div>
    <!--内容模态框-->
    <!--<div id="actionMask">-->
        <!--<div class="modal-dialog modal-lg" role="document">-->
            <!--<div class="modal-content">-->
                <!--<div class="modal-header">-->
                    <!--<button type="button" class="close actionCancelBtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>-->
                    <!--<h4 class="modal-title" id="actionMaskLabel">Modal title</h4>-->
                <!--</div>-->
                <!--<div class="modal-body actionMaskBody">-->

                <!--</div>-->
                <!--<div class="modal-footer">-->
                    <!--<button type="button" class="btn btn-default actionCancelBtn" data-dismiss="modal">取消</button>-->
                    <!--<button type="button" class="btn btn-primary actionSubmitBtn">提交</button>-->
                <!--</div>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
    <!--隐藏上传文件按钮-->
    <input id="hiddenUploadInput" type="file" style="display: none;" />
    <div class="actionMask">
        <div class="actionMaskContent">
            <div class="actionMaskHeader">
                <p>新增文章</p>
                <div class="closeBtn"></div>
            </div>
            <div class="actionMaskBody">

            </div>
            <div class="buttonGroup actionButtonGroup">
                <div class="buttonGroupCancelBtn actionCancelBtn">取消</div>
                <div class="buttonGroupSubmitBtn actionSubmitBtn">确定</div>
            </div>
        </div>
    </div>

    <div class="blackMask"></div>

    <script src="./js/jquery-2.2.1.min.js"></script>
    <script src="./js/bootstrap.min.js"></script>
    <!--<script src="./js/wangEditor.min.js"></script>-->
    <script src="./ue/ueditor.config.js"></script>
    <script src="./ue/ueditor.all.min.js"></script>
    <script src="./bootstrap/config.js"></script>
    <script src="./js/Vender.js"></script>
    <script>
        var ue = {};
        $(function(){

//            var editor = new wangEditor($('.wangEditor')[0]);
//            editor.create();

            function destoryUE()
            {
                for(w in ue){
                    ue[w].ue.destroy();
                }
                ue = {};
            }
//            function createInputForm(className,labelName,placeholder,value,allowChange)
//            {
//                var div = document.createElement('div');
//                div.setAttribute('class','formGroup');
//                var label = document.createElement('label');
//                label.innerText = labelName;
//                var input = document.createElement('input');
//                input.setAttribute('class',className);
//                input.setAttribute('type','text');
//                input.setAttribute('placeholder',placeholder);
//                if(value){
//                    input.value = value;
//                }
//                if(!allowChange){
//                    input.setAttribute('disabled','disabled');
//                }
//                div.appendChild(label);
//                div.appendChild(input);
//                return div;
//            }
//            function createSelectForm(className,labelName,optionArr,selectedValue,allowChange)
//            {
//                var div = document.createElement('div');
//                div.setAttribute('class','formGroup');
//                var label = document.createElement('label');
//                label.innerText = labelName;
//                var select = document.createElement('select');
//                select.setAttribute('class',className);
//                for(x in optionArr){
//                    var option = document.createElement('option');
//                    if(x == selectedValue){
//                        option.setAttribute('selected','selected');
//                    }
//                    option.setAttribute('value',x);
//                    option.innerText = optionArr[x];
//                    select.appendChild(option);
//                }
//                if(!allowChange){
//                    select.setAttribute('disabled','disabled');
//                }
//                div.appendChild(label);
//                div.appendChild(select);
//                return div;
//            }
//            function createCheckBoxForm(className,labelName,optionArr,selectedValue,allowChange)
//            {
//                var div = document.createElement('div');
//                div.setAttribute('class','formGroup');
//                var label = document.createElement('label');
//                label.innerText = labelName;
//                div.appendChild(label);
//                for(var x in optionArr){
//                    var input = document.createElement('input');
//                    for(var i=0;i<selectedValue.length;i++){
//                        if(optionArr[x] == selectedValue[i]){
//                            input.setAttribute('checked','checked');
//                            break;
//                        }
//                    }
//                    input.setAttribute('class',className);
//                    input.setAttribute('type','checkbox');
//                    input.setAttribute('value',x);
//                    if(!allowChange){
//                        input.setAttribute('disabled','disabled');
//                    }
//                    var span = document.createElement('span');
//                    span.innerText = optionArr[x];
//                    div.appendChild(input);
//                    div.appendChild(span);
//                }
//                return div;
//            }
//            function createUploadImageForm(className,labelName,value)
//            {
//                var div = document.createElement('div');
//                div.setAttribute('class','formGroup '+className+'Form');
//                var fileContent = document.createElement('div');
//                fileContent.setAttribute('class','fileContent');
//                var label = document.createElement('label');
//                label.innerText = labelName;
//                var input = document.createElement('input');
//                input.setAttribute('type','file');
//                input.setAttribute('class',className);
//                fileContent.appendChild(label);
//                fileContent.appendChild(input);
//                div.appendChild(fileContent);
//
//                if(value){
//                    var img = document.createElement('img');
//                    img.setAttribute('class','previewContent');
//                    img.setAttribute('src',value);
//
//                    div.appendChild(img);
//                }
//
//
//                $(input).on('change',function(){
//                    if(this.files.length){
//                        Upload(this.files[0],"http://testlaravel.geek-scorpion.com/newWorldGlasses/admin/image/upload",$(this).attr('class')+'Form');
//                    }
//                });
//                return div;
//            }
//            function createMoreUploadImageForm(className,labelName,valueArr)
//            {
//                var div = document.createElement('div');
//                div.setAttribute('class','formGroup '+className+'Form');
//                var fileContent = document.createElement('div');
//                fileContent.setAttribute('class','fileContent');
//                var label = document.createElement('label');
//                label.innerText = labelName;
//                var input = document.createElement('input');
//                input.setAttribute('type','file');
//                input.setAttribute('class',className);
//                fileContent.appendChild(label);
//                fileContent.appendChild(input);
//                div.appendChild(fileContent);
//                if(valueArr){
//                    for(var i=0;i<valueArr.length;i++){
//                        var img = document.createElement('img');
//                        img.setAttribute('class','previewContent');
//                        img.setAttribute('src',valueArr[i]);
//                        div.appendChild(img);
//                    }
//                }
//
//                $(input).on('change',function(){
//                    if(this.files.length){
//                        Upload(this.files[0],"http://testlaravel.geek-scorpion.com/newWorldGlasses/admin/image/upload",$(this).attr('class')+'Form');
//                    }
//                });
//                return div;
//            }
//            function createRichTextForm(className,labelName)
//            {
//                var div = document.createElement('div');
//                div.setAttribute('class','formGroup');
//                var label = document.createElement('label');
//                label.innerText = labelName;
//                var script = document.createElement('script');
//                script.setAttribute('id',className);
//                div.appendChild(label);
//                div.appendChild(script);
//                return div;
//            }
            function Upload(file,url,className)
            {
                var oData = new FormData();
                if(file){
                    oData.append("file",file);
                }

                var oReq = new XMLHttpRequest();
                oReq.open("POST",url, true);
                oReq.onload = function (oEvent) {
                    if (oReq.status == 200) {
                        var obj = JSON.parse(this.response);
                        if(obj.code == 1){
                            alert(obj.msg || obj.Msg);

                            var div_uploaded_img = document.createElement('div');
                            div_uploaded_img.setAttribute('class','uploadedImage');
                            var uploaded_img = document.createElement('img');
                            uploaded_img.setAttribute('class',className.split('_')[0]);
                            uploaded_img.setAttribute('src',obj.data.url);
                            var delete_img = document.createElement('img');
                            delete_img.setAttribute('class','imageDeleteBtn');
                            delete_img.setAttribute('src','./img/image_delete.png');
                            delete_img.setAttribute('alt','删除图片');

                            $(delete_img).on('click',function(){
                                $(this).parent('.uploadedImage').remove();
                            });

                            div_uploaded_img.appendChild(uploaded_img);
                            div_uploaded_img.appendChild(delete_img);
                            $('.'+className).append(div_uploaded_img);
                        }else{
                            alert(obj.msg || obj.Msg);
                        }
                    }
                    $('#hiddenUploadInput').val('');
                };
                oReq.send(oData);
            }
            function richTextSetContent()
            {
//                var curClass = window.localStorage.getItem('curPage');
//                for(var x in bootstrap[curClass].field){
//                    if(bootstrap[curClass].field[x].type == 'textarea'){
//                        ue[x].ue.ready(function(){
//                            this.setContent(ue[x].content);
//                        });
//                    }
//                }
                for(var x in ue){
                    ue[x].ue.ready(function(){
                        for(var y in ue){
                            ue[y].ue.setContent(ue[y].content);
                        }
                    });
                }
            }
            function ajaxTool(url,type,async,data,func)
            {
                $.ajax({
                    'url':url,
                    'async': async,
                    'type':type,
                    'data':data,
                    'dataType':'json',
                    'success':func
                });
            }
            function createActionContent(configName,data)
            {
                $('.actionMaskBody').html('');
                if(data){
//                    $('#actionMaskLabel').text('修改'+bootstrap[configName].title);
                    $('.actionMaskHeader p').text('修改'+bootstrap[configName].title);
                    for(q in bootstrap[configName].field){
                        var curField = bootstrap[configName].field[q];
                        switch(curField.type){
                            case 'text':
                                var div = window.Vender.createInput({
                                    labelName : curField.title,
                                    className : q,
                                    placeHolder : '请输入'+curField.title,
                                    value : data.data[q],
                                    optionObj: '',
                                    allowChange : curField.allowModify
                                });
                                $('.actionMaskBody').append(div);
                                break;
                            case 'select':
                                var optionArr = {};
                                for(var i=0;i<data.data[q+'_all'].length;i++){
                                    optionArr[data.data[q+'_all'][i].id] = data.data[q+'_all'][i].title;
                                }
                                var div = window.Vender.createSelect({
                                    labelName : curField.title,
                                    className : q,
                                    placeHolder : '',
                                    value : data.data[q],
                                    optionObj: optionArr,
                                    allowChange : curField.allowModify
                                });
                                $('.actionMaskBody').append(div);
                                break;
                            case 'MultiSelect':
                                var optionArr = {};
                                var valueArr = [];
                                for(var j=0;j<data.data[q].length;j++){
                                    valueArr.push(data.data[q][j].title);
                                }
                                for(var i=0;i<data.data[q+'_all'].length;i++){
                                    optionArr[data.data[q+'_all'][i].id] = data.data[q+'_all'][i].title;
                                }
                                var div = window.Vender.createCheckBox({
                                    labelName : curField.title,
                                    className : q,
                                    placeHolder : '',
                                    value : valueArr,
                                    optionObj: optionArr,
                                    allowChange : curField.allowModify
                                });
                                $('.actionMaskBody').append(div);
                                break;
                            case 'image':
                                var div = window.Vender.createImage({
                                    labelName : curField.title,
                                    className : q,
                                    placeHolder : '',
                                    value : data.data[q],
                                    optionObj: '',
                                    allowChange : curField.allowModify
                                });
                                $('.actionMaskBody').append(div);
                                break;
                            case 'MultiImage':
                                var valueArr = [];
                                for(var i=0;i<data.data[q].length;i++){
                                    valueArr.push(data.data[q][i].image);
                                }
                                var div = window.Vender.createMoreImage({
                                    labelName : curField.title,
                                    className : q,
                                    placeHolder : '',
                                    value : valueArr,
                                    optionObj: '',
                                    allowChange : curField.allowModify
                                });
                                $('.actionMaskBody').append(div);
                                break;
                            case 'textarea':
                                var value = data.data[q];
                                var div = window.Vender.createRichTextarea({
                                    labelName : curField.title,
                                    className : q,
                                    placeHolder : '',
                                    value : value,
                                    optionObj: '',
                                    allowChange : curField.allowModify
                                });
                                $('.actionMaskBody').append(div);
//                                var editor = new wangEditor($('.'+q)[0]);
//                                editor.config.uploadImgUrl = '/resource/upload';
//                                editor.create();
//                                ue[q] = {
//                                    'ue':editor,
//                                    'content':value
//                                };
                                var editor = UE.getEditor(q,{
                                    initialFrameHeight:280
                                });
                                ue[q] = {
                                    'ue':editor,
                                    'content':value
                                };
                                break;
                        }
                    }
                }else{
//                    $('#actionMaskLabel').text('添加'+bootstrap[configName].title);
                    $('.actionMaskHeader p').text('修改'+bootstrap[configName].title);
                    for(q in bootstrap[configName].field){
                        var curField = bootstrap[configName].field[q];
                        switch(curField.type){
                            case 'text':
                                var div = window.Vender.createInput({
                                    labelName : curField.title,
                                    className : q,
                                    placeHolder : '请输入'+curField.title,
                                    value : '',
                                    optionObj: '',
                                    allowChange : curField.allowModify
                                });
                                $('.actionMaskBody').append(div);
                                break;
                            case 'select':
                                ajaxTool(bootstrap[configName].field[q].allURL,'get',false,{},function(data){
                                    var optionArr = {};
                                    for(var i=0;i<data.data.length;i++){
                                        optionArr[data.data[i].id] = data.data[i].title;
                                    }
                                    var div = window.Vender.createSelect({
                                        labelName : curField.title,
                                        className : q,
                                        placeHolder : '',
                                        value : '',
                                        optionObj: optionArr,
                                        allowChange : curField.allowModify
                                    });
                                    $('.actionMaskBody').append(div);
                                });
                                break;
                            case 'MultiSelect':
                                ajaxTool(bootstrap[configName].field[q].allURL,'get',false,{},function(data){
                                    var optionArr = {};
                                    for(var i=0;i<data.data.length;i++){
                                        optionArr[data.data[i].id] = data.data[i].title;
                                    }
                                    var div = window.Vender.createCheckBox({
                                        labelName : curField.title,
                                        className : q,
                                        placeHolder : '',
                                        value : '',
                                        optionObj: optionArr,
                                        allowChange : curField.allowModify
                                    });
                                    $('.actionMaskBody').append(div);
                                });
                                break;
                            case 'image':
                                var div = window.Vender.createImage({
                                    labelName : curField.title,
                                    className : q,
                                    placeHolder : '',
                                    value : '',
                                    optionObj: '',
                                    allowChange : ''
                                });
                                $('.actionMaskBody').append(div);
                                break;
                            case 'MultiImage':
                                var div = window.Vender.createMoreImage({
                                    labelName : curField.title,
                                    className : q,
                                    placeHolder : '',
                                    value : '',
                                    optionObj: '',
                                    allowChange : ''
                                });
                                $('.actionMaskBody').append(div);
                                break;
                            case 'textarea':
                                var div = window.Vender.createRichTextarea({
                                    labelName : curField.title,
                                    className : q,
                                    placeHolder : '',
                                    value : '',
                                    optionObj: '',
                                    allowChange : ''
                                });
                                $('.actionMaskBody').append(div);
//                                var editor = new wangEditor($('.'+q)[0]);
//                                editor.create();
//                                ue[q] = {
//                                    'ue':editor,
//                                    'content':''
//                                };
//                                var editor = new wangEditor($('.wangEditor')[0]);
//                                editor.create();
                                var editor = UE.getEditor(q,{
                                    initialFrameHeight:280
                                });
                                ue[q] = {
                                    'ue':editor,
                                    'content':''
                                };
                                break;
                        }
                    }
                }
//                $('#actionMask').modal('show');
                $('.blackMask').fadeIn();
                $('.actionMask').fadeIn();
            }
            //搜索点击按钮
            $('.searchBtn').on('click',function(){
                var curClass = 'articleManage';
                window.localStorage.setItem('curPage',curClass);
                $('.bodyTitle p').text(bootstrap[curClass].title);
                if(bootstrap[curClass].allowAdd){
                    $('.bodyContent .actionContent').css('visibility','visible');
                }else{
                    $('.bodyContent .actionContent').css('visibility','hidden');
                }
                bootstrap[curClass].getList.data.curPage = 1;
                bootstrap[curClass].getList.data.search = $('.searchContent input').val();
                createHTML(curClass);
            });
            $('.closeBtn').on('click',function(){
                destoryUE();
//                $('#actionMask').modal('hide');
                $('.blackMask').fadeOut();
                $('.actionMask').fadeOut();
            });
            //内容模态框按钮事件
            $('.actionCancelBtn').on('click',function(){
                destoryUE();
//                $('#actionMask').modal('hide');
                $('.blackMask').fadeOut();
                $('.actionMask').fadeOut();
            });
            $('.actionAddBtn').on('click',function(){
                var curClass = window.localStorage.getItem('curPage');
                createActionContent(curClass,'');
//                $('#actionMask').modal('show');
                $('.blackMask').fadeIn();
                $('.actionMask').fadeIn();
            });
            $('.actionSubmitBtn').on('click',function(){
                var curClass = window.localStorage.getItem('curPage');
                var data = {};
                for(x in bootstrap[curClass].field){
                    switch (bootstrap[curClass].field[x].type){
                        case 'text':
                                data[x] = $('.'+x).val();
                            break;
                        case 'select':
                                data[x] = $("input[name='"+x+"']:checked").val();
                            break;
                        case 'MultiSelect':
                                var str = '';
                                $("input[name='"+x+"']:checked").each(function(){
                                    str += $(this).val()+',';
                                });
                                data[x] = str;
                            break;
                        case 'image':
                                data[x] = $('.'+x+':last').attr('src') || '';
                            break;
                        case 'MultiImage':
                                var str = '';
                                $('.'+x).each(function(){
                                    str += $(this).attr('src')+',';
                                });
                                data[x] = str;
                            break;
                        case 'textarea':
                                data[x] = ue[x].ue.getContent();
                            break;
                    }
                }
//                console.dir(data);
                ajaxTool(bootstrap[curClass].setInfo.url,'post',true,data,function(data){
                    alert(data.msg);
                    if(data.code == 1){
                        destoryUE();
                        $('.blackMask').fadeOut();
                        $('.actionMask').fadeOut();
                    }
//                    $('#actionMask').modal('hide');
                });
            });

            //删除模态框按钮事件
            $('.deleteCancelBtn').on('click',function(){
                window.localStorage.removeItem('curDID');
                $('#deleteModal').modal('hide');
            });
            $('.deleteSubmitBtn').on('click',function(){
                var id = window.localStorage.getItem('curDID');
                var curClass = window.localStorage.getItem('curPage');
                ajaxTool(bootstrap[curClass].deleteInfo.url,'post',true,{'id':id},function(data){
                    alert(data.msg);
                    window.localStorage.removeItem('curDID');
                    $('#deleteModal').modal('hide');
                });
            });

            //上传按钮change事件
            $('#hiddenUploadInput').on('change',function(){
                var curOuterClass = window.localStorage.getItem('outerClass') || '';
                if(this.files.length && curOuterClass){
                    Upload(this.files[0],"http://120.55.180.184/school/admin/image/upload",curOuterClass);
                }
            });

            //生成架构
            for(variable in bootstrap){
                var li_nav = document.createElement('li');
                li_nav.setAttribute('class',variable);
                var div = document.createElement('div');
                div.setAttribute('class','iconContent');
                var span = document.createElement('span');
                span.innerText = bootstrap[variable].title;
                li_nav.appendChild(div);
                li_nav.appendChild(span);
                $('.navContent ul').append(li_nav);
                //对应栏目点击ajax事件
                $(li_nav).on('click',function(){
                    var curClass = $(this).attr('class');
                    window.localStorage.setItem('curPage',curClass);
                    $('.bodyTitle p').text(bootstrap[curClass].title);
                    if(bootstrap[curClass].allowAdd){
                        $('.bodyContent .actionContent').css('visibility','visible');
                    }else{
                        $('.bodyContent .actionContent').css('visibility','hidden');
                    }
                    bootstrap[curClass].getList.data.curPage = 1;
                    createHTML(curClass);
                });
            }
            function createHTML(curClass)
            {
                $.ajax({
                    'url':bootstrap[curClass].getList.url,
                    'type':'get',
                    'data':bootstrap[curClass].getList.data,
                    'dataType':'json',
                    'success':function(data){
                        //初始化内容表格
                        $('.bodyContent table tbody').html("");
                        if(data.code == 1){
                            //设置总页数
                            bootstrap[curClass].getList.data.totalPage = data.data.totalPage;
                            //设置表格头
                            var tr = document.createElement('tr');
                            var th = document.createElement('th');
                            tr.appendChild(th);
                            var fieldArr = [];  //字段数组，与后面的表格内容中的i对应
                            for(x in bootstrap[curClass].field){
                                if(bootstrap[curClass].field[x].showFront){
                                    fieldArr.push(x);
                                    var th = document.createElement('th');
                                    th.innerText = bootstrap[curClass].field[x].title;
                                    tr.appendChild(th);
                                }
                            }
                            //生成操作表头
                            var th = document.createElement('th');
                            th.innerText = '操作';
                            tr.appendChild(th);
                            $('.bodyContent table tbody').append(tr);

                            //生成表格内容
                            for(var i=0;i<data.data.data.length;i++){
                                var tr = document.createElement('tr');
                                var td = document.createElement('td');
                                var td_input = document.createElement('input');
                                td_input.setAttribute('type','checkbox');
                                td.appendChild(td_input);
                                tr.appendChild(td);
                                for(y in data.data.data[i]){
                                    var td = document.createElement('td');
                                    if(y == 'id'){
                                        td.setAttribute('class','curId');
                                    }
                                    td.innerText = data.data.data[i][y];
                                    tr.appendChild(td);
                                }
                                $('.bodyContent table tbody').append(tr);

                                //生成操作表内容
                                var td = document.createElement('td');
                                //允许修改
                                if(bootstrap[curClass].allowModify){
                                    var div = document.createElement('div');
                                    div.setAttribute('class','editBtn');
                                    var img = document.createElement('img');
                                    img.setAttribute('src','./img/edit_icon.png');
                                    img.setAttribute('alt','编辑');
                                    var span = document.createElement('span');
                                    span.innerText = '编辑';
                                    div.appendChild(img);
                                    div.appendChild(span);
                                    td.appendChild(div);
                                    //修改点击事件
                                    $(div).on('click',function(){
                                        var  cur_id = $(this).parents('td').siblings('.curId').text();
                                        bootstrap[curClass].getInfo.data.id = cur_id;
                                        $.ajax({
                                            'url':bootstrap[curClass].getInfo.url,
                                            'type':'get',
                                            'data':bootstrap[curClass].getInfo.data,
                                            'dataType':'json',
                                            'success':function(data){
                                                if(data.code == 1){
                                                    var curClass = window.localStorage.getItem('curPage');
                                                    createActionContent(curClass,data);
                                                    richTextSetContent();
                                                }else{
                                                    alert(data.msg);
                                                }

                                            }
                                        });
                                    });
                                }
                                //允许删除
                                if(bootstrap[curClass].allowDelete){
                                    var div = document.createElement('div');
                                    div.setAttribute('class','deleteBtn');
                                    var img = document.createElement('img');
                                    img.setAttribute('src','./img/delete_icon.png');
                                    img.setAttribute('alt','删除');
                                    var span = document.createElement('span');
                                    span.innerText = '删除';
                                    div.appendChild(img);
                                    div.appendChild(span);
                                    td.appendChild(div);
                                    $(div).on('click',function(){
                                        var  cur_id = $(this).parents('td').siblings('.curId').text();
                                        window.localStorage.setItem('curDID',cur_id);
                                        $('#deleteModal').modal('show');
                                    });
                                }
                                tr.appendChild(td);
                                $('.bodyContent table tbody').append(tr);
                            }

                            //生成分页按钮
                            var tr = document.createElement('tr');
                            var td = document.createElement('td');
                            td.setAttribute('colspan',fieldArr.length+2);
                            var div = document.createElement('div');
                            div.setAttribute('class','pageContent');
                            var numberAndTotalNumberDiv = document.createElement('div');
                            numberAndTotalNumberDiv.setAttribute('class','numberAndTotalNumber');
                            var input = document.createElement('input');
                            input.setAttribute('type','text');
                            input.value = data.data.curPage;
                            var span = document.createElement('span');
                            span.innerText = "/"+data.data.totalPage;
                            numberAndTotalNumberDiv.appendChild(input);
                            numberAndTotalNumberDiv.appendChild(span);
                            div.appendChild(numberAndTotalNumberDiv);
                            var ul = document.createElement('ul');
                            var li = document.createElement('li');
                            li.setAttribute('class','beforeBtn');
                            li.innerText = '上一页';
                            ul.appendChild(li);
                            if(data.data.curPage > 1){
                                //上一页点击事件
                                $(li).on('click',function(){
                                    var cur_class = window.localStorage.getItem('curPage');
                                    bootstrap[curClass].getList.data.curPage = parseInt(data.data.curPage) - 1;
                                    createHTML(cur_class);
                                });
                            }
                            for(var j=1;j<=data.data.totalPage;j++){
                                var li = document.createElement('li');
                                li.setAttribute('class','pageNumber');
                                li.innerText = j;
                                ul.appendChild(li);
                                //页码点击事件
                                $(li).on('click',function(){
                                    var cur_class = window.localStorage.getItem('curPage');
                                    bootstrap[curClass].getList.data.curPage = $(this).text();
                                    createHTML(cur_class);
                                });
                            }
                            var li = document.createElement('li');
                            li.setAttribute('class','afterBtn');
                            li.innerText = '下一页';
                            ul.appendChild(li);
                            //下一页点击事件
                            $(li).on('click',function(){
                                var cur_class = window.localStorage.getItem('curPage');
                                if(bootstrap[curClass].getList.data.curPage < bootstrap[curClass].getList.data.totalPage){
                                    bootstrap[curClass].getList.data.curPage = parseInt(data.data.curPage) + 1;
                                    createHTML(cur_class);
                                }else{
                                    alert('已经是最后一页了');
                                }
                            });
                            var li = document.createElement('li');
                            li.setAttribute('class','lastBtn');
                            li.innerText = '最后一页';
                            ul.appendChild(li);
                            //最后一页点击事件
                            $(li).on('click',function(){
                                var cur_class = window.localStorage.getItem('curPage');
                                if(bootstrap[curClass].getList.data.curPage == bootstrap[curClass].getList.data.totalPage){
                                    alert('已经是最后一页了');
                                }else{
                                    bootstrap[curClass].getList.data.curPage = bootstrap[curClass].getList.data.totalPage;
                                    createHTML(cur_class);
                                }
                            });
                            div.appendChild(ul);
                            td.appendChild(div);
                            tr.appendChild(td);
                            $('.bodyContent table tbody').append(tr);

                        }else{
                            alert(data.msg);
                        }
                    }
                });
            }
        });
    </script>
</body>
</html>